package com.quasar.hpatient.presenter;

import com.quasar.hpatient.model.httpmodel.DataStateResult;
import com.quasar.hpatient.model.medicalmodel.ClonePrescriptionData;
import com.quasar.hpatient.model.requestmodel.RequestModel;
import com.quasar.hpatient.onInterface.AnotherResultListener;
import com.quasar.hpatient.onInterface.OnPrescriptionListener;
import com.vise.log.ViseLog;

/**
 * author : 许建宏
 * Date: 2017/11/13 0013
 * View: 药单信息
 */

public class PrescriptionPresenter {

    private RequestModel requestModel;
    private OnPrescriptionListener uiInterface;

    public PrescriptionPresenter(OnPrescriptionListener uiInterface) {
        this.uiInterface = uiInterface;
        this.requestModel = new RequestModel();
    }

    //添加用药
    public void AddPrescriptionData(String medicineId, String startTime, String howtoUse,
                                    String howLong, String list,
                                    String editMessage, String doctorId,
                                    String id, String periodEnd,String mName,String doseName,
                                    String packages,String useInterval,String timeLen,
                                    String prescription) {

        requestModel.AddPrescriptionData(medicineId, startTime, howtoUse,
                howLong, list, editMessage, doctorId, id, periodEnd,
                mName,doseName,packages,useInterval,timeLen,prescription,
                new AnotherResultListener<DataStateResult>() {
            @Override
            public void onSuccess(DataStateResult data) {
                uiInterface.onSuccess(data);
            }

            @Override
            public void onError(String msg) {
                uiInterface.onError(msg);
                ViseLog.d("新增药单"+msg);
            }

            @Override
            public void onRefreshUI() {
                uiInterface.onRefreshUI();
            }
        });
    }

    //克隆药单
    public void ClonePrescriptionData(String doctorId,String startTime,String mName,String doseName){

        requestModel.ClonePrescriptionData(doctorId, startTime,mName,doseName, new AnotherResultListener<ClonePrescriptionData>() {
            @Override
            public void onSuccess(ClonePrescriptionData data) {
                uiInterface.onClonePrescription(data);
            }

            @Override
            public void onError(String msg) {
                uiInterface.onError(msg);
                ViseLog.d("克隆"+msg);
            }

            @Override
            public void onRefreshUI() {
                uiInterface.onRefreshUI();
            }
        });
    }

    //删除药单
    public void DeletePrescriptionData(String doctorId,String id,String editMessage,String prescription){

        requestModel.DeletePrescriptionData(doctorId, id, editMessage,prescription, new AnotherResultListener<DataStateResult>() {
            @Override
            public void onSuccess(DataStateResult data) {
                uiInterface.onDeletePrescription(data);
            }

            @Override
            public void onError(String msg) {
                uiInterface.onError(msg);
            }

            @Override
            public void onRefreshUI() {
                uiInterface.onRefreshUI();
            }
        });
    }

    //修改药单
    public void updatePrescriptionData(String doctorId,String pdid,
                                       String mid,String editType,
                                       String startTime,String howtoUse,
                                       String howLong,String list,
                                       String editMessage,
                                       String id,
                                       String periodEnd,
                                       String mName,
                                       String doseName,
                                       String packages,
                                       String useInterval, String timeLen,String prescription){

        requestModel.updatePrescriptionData(doctorId, pdid, mid,
                editType, startTime, howtoUse, howLong, list,
                editMessage, id, periodEnd,mName,doseName,packages,useInterval, timeLen,prescription,
                new AnotherResultListener<DataStateResult>() {
            @Override
            public void onSuccess(DataStateResult data) {
                uiInterface.onUpPrescription(data);
            }

            @Override
            public void onError(String msg) {
                uiInterface.onError(msg);
            }

            @Override
            public void onRefreshUI() {
                uiInterface.onRefreshUI();
            }
        });
    }
}
